/**
 * Created by smp on 2017/6/9.
 */
var modelPath=ROOT_PATH+'/observation/statisticsAnalysis/';
function toDate(){
    var date=new Date();
    var year=date.getFullYear();
    var month=date.getMonth()+1;
    if(month<10)
        month="0"+month;
    var day=date.getDate();
    if(day<10)
        day="0"+day;
    return year+"-"+month+"-"+day;
}
$(function () {
    var ate=new Date();
    $("#beginTime").datebox('setValue', ate.getFullYear()+"-01-01");
    $("#endTime").datebox('setValue', toDate());
    $("#contractor").css("display","inline");

    $('#dg1').datagrid({
        method: 'post',
        url: modelPath + 'contractorBeanList.shtml',
        queryParams: {
            contractorName: $("#contractorName").textbox('getValue'),
            beginTime:$("#beginTime").datebox('getValue'),
            endTime:$("#endTime").datebox('getValue')
        },
        toolbar:'#tb1',
        //idField: 'id',
        fitColumns: true,
        pagination: true,
        rownumbers: true,
        sortOrder: true,
        striped: true,
        singleSelect:true,
        fit: true,
        columns: [[
            {field: 'deptId', width: 80, checkbox: true},
            {field: 'deptName', title: '承包商名称', width: 100,  sortable: true},
            {field: 'allCount', title: '合计', width: 80,  sortable: true},
            {field: 'actCount', title: '不安全行为', width: 100, sortable: true},
            {field: 'stateCount', title: '不安全状态', width: 100, sortable: true},
            {field: 'safeActCount', title: '推荐安全行为', width: 100, sortable: true}
        ]]
    });
    $('#btn_clear').on("click", function () {
        $('#tb1').form('reset');
    });
    $('#btn_search').on("click", function () {
        $('#dg1').datagrid('load', {beginTime:$("#beginTime").datebox('getValue'),
            endTime:$("#endTime").datebox('getValue'),contractorName: $("#contractorName").textbox('getValue')});
    });
});
